package Java1Test.ArrayList;

import java.util.ArrayList;

public class ArrayListTest6 {
    public static void main(String[] args) {
        ArrayList<Phone> list = new ArrayList<>();
        Phone p1 = new Phone("小米", 1000);
        Phone p2 = new Phone("苹果", 8000);
        Phone p3 = new Phone("锤子", 2999);
        list.add(p1);
        list.add(p2);
        list.add(p3);
        System.out.println(getPhoneInfoByPrice(list, 3000));
    }

    public static ArrayList<Phone> getPhoneInfoByPrice(ArrayList<Phone> list, int price) {
        ArrayList<Phone> list1 = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getPrice() < price){
                list1.add(list.get(i));
            }

        }
        return list1;
    }
}
